package com.mixed;

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
 
public class GetShell extends HttpServlet {
    private static String shellpath = "/opt/tomcat8/webapps/encrypt/shell/Mixed-Encrypt-Decrypt.tar.gz";
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
            File f = new File(shellpath);  
            if(f.exists()){  
                FileInputStream in = new FileInputStream(f);
                byte[] b = new byte[in.available()];  
                in.read(b);  
                response.setCharacterEncoding("utf-8");  
                response.setHeader("Content-Disposition","attachment;filename=Mixed-Encrypt-Decrypt.tar.gz");  
                //获取响应报文输出流对象  
                ServletOutputStream out =response.getOutputStream();  
                out.write(b);  
                out.flush();  
                out.close();  
            }     
        }
}
